package com.blog.controller;

import com.blog.domain.ResponseResult;
import com.blog.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/article")
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    /**热门文章查询
     *
     * @return
     */
    @GetMapping("/hotArticleList")
    public ResponseResult hotArticleList(){
        //查询热门文章并封装
        ResponseResult result = articleService.hotArticleList();
        return result;
    }

    /**分页查询文章列表
     *
     * @return
     */
    @GetMapping("/articleList")
    public ResponseResult articleList(Integer pageNum,Integer pageSize,Long categoryId){
        return articleService.articleList(pageNum,pageSize,categoryId);
    }


    /**文章详情
     *
     */
    @GetMapping("/{id}")
    public ResponseResult getArticleDetail(@PathVariable Long id){

        return articleService.getArticleDetail(id);

    }

    /**更新redis中的文章浏览量
     *
     * @param id
     * @return
     */

    @PutMapping("/updateViewCount/{id}")
    public ResponseResult updateViewCount(@PathVariable("id") Long id){

        return articleService.updateViewCount(id);

    }


}
